package Lexer;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;


public class Lexer {
    private String source;
    private TokenTable tokenTable;

    private List<String> kws;

    public Lexer(File f, TokenTable tokenTable) {
        try {
            InputStream in = new FileInputStream(f);
            int temp;
            this.source = "";
            while ((temp = in.read()) != -1) {
                this.source += (char) temp;
            }
            this.source += ' ';
            in.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
        this.tokenTable = tokenTable;
        //this.dfa = new DFA();
        kws = new ArrayList<String>();
        kws.add("int");
        kws.add("void");
        kws.add("return");
        kws.add("const");
        kws.add("main");
    }


    private int getPointer(String lexeme) {
        switch (lexeme) {
            case "int":
                return 1;
            case "void":
                return 2;
            case "return":
                return 3;
            case "const":
                return 4;
            case "main":
                return 5;
            case "+":
                return 6;
            case "-":
                return 7;
            case "*":
                return 8;
            case "/":
                return 9;
            case "%":
                return 10;
            case "=":
                return 11;
            case ">":
                return 12;
            case "<":
                return 13;
            case "==":
                return 14;
            case "<=":
                return 15;
            case ">=":
                return 16;
            case "!=":
                return 17;
            case "&&":
                return 18;
            case "||":
                return 19;
            case "(":
                return 20;
            case ")":
                return 21;
            case "{":
                return 22;
            case "}":
                return 23;
            case ";":
                return 24;
            case ",":
                return 25;
        }
        return -1;
    }
}
